<?php
header("Content-Type: application/json");
include('../../include/functions.inc.php');
$strQuery ='SELECT  serie,
                    numero,
                    fecha,
                    nit,
                    nombre,
                    total monto,
                    id
            FROM    cllg_factura
            WHERE   status = 2';
$facturas = $db->queryToArray($strQuery);
$strJson = '';
reset($facturas);
while( $arrTMP = each($facturas) ) {
    $arr = array();
    $arr['SERIE'] = $arrTMP['value']['serie'];
    $arr['NUMERO'] = $arrTMP['value']['numero'];
    $arr['FECHA'] = $arrTMP['value']['fecha'];
    $arr['NIT'] = $arrTMP['value']['nit'];
    $arr['NOMBRE'] = $arrTMP['value']['nombre'];
    $arr['MONTO'] = round($arrTMP['value']['monto'], 2);
    $arr['ID'] = $arrTMP['value']['id'];
    $strJson .= empty($strJson) ? '' : ',';
    $strJson .= json_encode($arr);
}
print '['.$strJson.']';
//$facturas = $db->query_toJson("cllg_factura", "STATUS=2", array("SERIE" => "SERIE", "NUMERO" => "NUMERO", "FECHA" => "FECHA", "NIT" => "NIT", "NOMBRE" => "NOMBRE", "MONTO" => "TOTAL", "ID" => "ID"));
//echo $facturas;
?>